﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Web;

namespace PersonJSONService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IPersonJsonService" in both code and config file together.
    [ServiceContract]
    public interface IPersonJsonService
    {
        [OperationContract]
        [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, 
            ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetPeople")]
        Person[] GetPeople();

        [OperationContract]
        [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare,
            ResponseFormat = WebMessageFormat.Json, UriTemplate = "SavePerson?name={name}&lastname={lastname}&age={age}")]
        Person[] SavePerson(string name,string lastname,string age);
    }


    [DataContract(Name = "Person")]
    public class Person
    {
        [DataMember(Name = "firstName")]
        public string firstName { get; set; }
        [DataMember(Name = "lastName")]
        public string lastName { get; set; }
        [DataMember(Name = "age")]
        public int age { get; set; }
    }
}
